package operations;

import book.Booklist;

import java.util.Scanner;

public class BorrowOperation implements Operation{
    public void work(Booklist booklist){
        System.out.println("借阅图书......");
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入你要借阅的书的书名");
        String name = scanner.nextLine();

        for (int i = 0; i < booklist.getUesdSize(); i++){
            if(booklist.getBook(i).getName().equals(name)){
                if (booklist.getBook(i).isIsborrowed() ){
                    System.out.println("该书已被借出");
                    return;
                }
                booklist.getBook(i).setIsborrowed(true);
                System.out.println("借阅成功！！！");
                return;
            }
        }
        System.out.println("查无此书");
    }
}
